package com.example.color_test.mapper;

import com.example.color_test.entity.Img;
import com.example.color_test.entity.Record;
import org.apache.ibatis.annotations.*;
import org.springframework.stereotype.Repository;

import java.util.List;

/**
 * record
 * @author 大狼狗
 * @date 2021/02/21
 */
@Mapper
@Repository
public interface RecordMapper {



    /**
     * [新增]
     * @author 大狼狗
     * @date 2021/02/21
     **/
    int insert(Record record);

    /**
     * [刪除]
     * @author 大狼狗
     * @date 2021/02/21
     **/
    int delete(int id);

    /**
     * [更新]
     * @author 大狼狗
     * @date 2021/02/21
     **/
    int update(Record record);

    /**
     * [查询] 根据主键 id 查询
     * @author 大狼狗
     * @date 2021/02/21
     **/
    Record load(int id);

    /**
     * 查询历史图片
     * @param offset
     * @param pagesize
     * @return
     */
    @Select("select * FROM record ORDER BY ABS(time) desc ")
    List<Record> selectRecords();

    @Select("select * FROM record where id < #{firstId} ORDER BY ABS(time) desc ")
    List<Record> selectRecordsByLastId(int firstId);

    /**
     * [查询] 分页查询
     * @author 大狼狗
     * @date 2021/02/21
     **/
    List<Record> pageList(int offset, int pagesize);

    /**
     * [查询] 分页查询 count
     * @author 大狼狗
     * @date 2021/02/21
     **/
    int pageListCount(int offset,int pagesize);

    @Select("select * from record")
    List<Record> findAll();

}